import { request } from '@/utils/request';
import { Device } from '@/types/device';

const BASE_URL = '/api/devices';

export async function getDevices(): Promise<Device[]> {
  return request.get(BASE_URL);
}

export async function getDeviceById(id: number): Promise<Device> {
  return request.get(`${BASE_URL}/${id}`);
}

export async function updateDeviceStatus(id: number, status: boolean): Promise<Device> {
  return request.put(`${BASE_URL}/${id}/status`, { status });
} 